package com.fan.controller;

import com.fan.entity.Chapter;
import com.fan.service.ChapterService;
import com.fan.utils.CommonResults;
import com.sixth.until.CommonResult;
import io.swagger.annotations.Api;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: self-tui-education
 * @description:
 * @author: 老范
 * @create: 2022-04-28 20:46
 **/
@RestController
@RequestMapping("/order/chapter")
@Api(tags = "ChapterController")
public class ChapterController {

    @Autowired
    private ChapterService chapterService;

    @PostMapping("findChapterByCourseId/{courseId}")
    public CommonResult findChapterByCourseId(@PathVariable String courseId) {
        return chapterService.findChapterByCourseId(courseId);
    }
    @PostMapping("/findChapterById/{id}")
    public CommonResults findChapterById(@PathVariable String id){
        return chapterService.findChapterById(id);
    }

    @PostMapping("/insertChapterWithCourseId")
    public CommonResults insertChapter(@RequestBody Chapter chapter){
        return chapterService.insertChapter(chapter);
    }

    @PostMapping("/deleteChapterWithCourseId")
    public CommonResults deleteChapterWithCourseId(@RequestBody Chapter chapter) {
        return chapterService.deleteChapterWithCourseId(chapter);
    }
}

